import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state:{
    HOST: 'http://127.0.0.1',
    activeName: '',   // 前台当前选中的菜单名
  },
  getters:{
    activeName: state => {
      let activeName = state.activeName;
      if(!activeName){
        activeName = JSON.parse(window.sessionStorage.getItem('activeName'));
      }
      return activeName;
    }
  },
  mutations:{
    setActiveName: (state,activeName) => {
      state.activeName = activeName;
      window.sessionStorage.setItem('activeName',JSON.stringify(activeName));
    }
  },
})
